// 任务管理

import { http } from "@/utils/http";
import { baseUrlApi } from "../utils";
type Result = {
  data: any;
  status: number;
  msg: string;
  success: boolean;
  isSuccess?: boolean;
};

type ResultOrganization = {
  success: boolean;
  data?: {
    list: Array<any>;
    totalCount: number;
    pageSize: number;
    pageIndex: number;
  };
};

/** 根据计划ID查询任务 */
export const TaskGetPage = (data?: any) => {
  return http.request<ResultOrganization>(
    "post",
    baseUrlApi("/Task/GetAllByPagedAndSort"),
    {
      data
    }
  );
};

/** 保存任务 */
export const TaskSave = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("/Task/Save"), {
    data
  });
};


//查看计划下的分数
export const GetAllModuleScoresByPlanId = (params: string) => {
  return http.request<any>(
    "get",
    "/api/task/GetAllModuleScoresByPlanId?" + params
  );
};

/** 修改任务 */
export const TaskUpdate = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("/Task/Update"), {
    data
  });
};

/** 删除任务 */
export const TaskDelete = (params?: object) => {
  return http.request<Result>("post", baseUrlApi("/Task/Delete"), {
    params
  });
};

// 获取子模块
export const GetSelectItemBySelectType = (params: string) => {
  return http.request<Result>(
    "get",
    "/api/Submodule/GetSubmoduleByModuleId?moduleId=" + params
  );
};

// 任务明细管理

//保存任务详情--关键字
export const TaskDetailSaev = (data: object) => {
  return http.request<Result>("post", baseUrlApi("/TaskDetail/Save"), { data });
};

//修改任务详情--关键字
export const TaskDetailUpdate = (data: object) => {
  return http.request<Result>("post", baseUrlApi("/TaskDetail/Update"), {
    data
  });
};

// 明细序列号
export const TaskGetDetailSortNo = (params: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/TaskDetail/GetDetailSortNo?" + params)
  );
};

// 获取任务详情列表
export const TaskDetailGetPage = (params: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/TaskDetail/GetPage?" + params)
  );
};

// 删除任务明细
export const TaskDeleteDetail = (params?: object) => {
  return http.request<Result>(
    "post",
    baseUrlApi("/TaskDetail/Delete?id=" + params)
  );
};

// 查询任务明细  true
export const GetTaskDetailById = (params?: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/TaskDetail/GetTaskDetailById?detailId=" + params)
  );
};

// 查询任务明细
export const GetTaskDetailKeyword = (params?: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/SubmoduleKeywrod/GetTaskDetailKeyword?" + params)
  );
};

// 查询任务明细
export const GetTaskAllDetailKeyword = (params?: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/TaskKeyword/GetTaskAllKeyword?detailId=" + params)
  );
};

// 修改任务详情
export const TaskGetTaskDetail = (params?: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/Task/GetTaskDetail?" + params)
  );
};

// /SubmoduleKeywrod/GetSubmoduleKeywordBySubmoduleId?
// 根据子模块ID 查询模块设置相对应的关键字

export const GetSubmoduleKeywordBySubmoduleId = (params?: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi(
      "/SubmoduleKeywrod/GetSubmoduleKeywordBySubmoduleId?submoduleId=" + params
    )
  );
};

// 根据模块ID和keyworkid获取关键字列表
export const GetBySubmoduleIdAndKeywordId = (params?: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/SubmoduleKeywrod/GetBySubmoduleIdAndKeywordId?" + params)
  );
};

// 保存关键字接口
export const TaskKeywordSave = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("/TaskKeyword/Save"), {
    data
  });
};

//修改任务状态
export const TaskDisEnableOrEnable = (params: string) => {
  return http.request<Result>(
    "post",
    baseUrlApi("/TaskArrangement/DisEnableOrEnable?" + params)
  );
};
//关闭任务
export const TaskClose = (params: string) => {
  return http.request<Result>(
    "post",
    baseUrlApi("/TaskArrangement/Close?" + params)
  );
};
//获取单条任务数据
export const TaskGetone = (params: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/TaskArrangement/Get?" + params)
  );
};
//修改任务
export const Update = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("/TaskArrangement/Update"), {
    data
  });
};
